#!/bin/bash

# 创建上传目录的脚本

# 设置项目根目录
PROJECT_ROOT="."

# 创建图片上传目录
IMAGES_DIR="$PROJECT_ROOT/upload/images"
echo "创建图片上传目录: $IMAGES_DIR"
mkdir -p "$IMAGES_DIR"

# 创建头像上传目录
AVATARS_DIR="$PROJECT_ROOT/upload/avatars"
echo "创建头像上传目录: $AVATARS_DIR"
mkdir -p "$AVATARS_DIR"

# 创建静态资源目录中的上传目录
STATIC_IMAGES_DIR="$PROJECT_ROOT/src/main/resources/static/upload/images"
echo "创建静态资源图片目录: $STATIC_IMAGES_DIR"
mkdir -p "$STATIC_IMAGES_DIR"

# 创建静态资源目录中的头像目录
STATIC_AVATARS_DIR="$PROJECT_ROOT/src/main/resources/static/upload/avatars"
echo "创建静态资源头像目录: $STATIC_AVATARS_DIR"
mkdir -p "$STATIC_AVATARS_DIR"

# 设置权限
chmod -R 755 "$PROJECT_ROOT/upload"
chmod -R 755 "$PROJECT_ROOT/src/main/resources/static/upload"

echo "上传目录初始化完成"

# Create a test upload directory for today
TODAY=$(date +%Y%m%d)
mkdir -p "$IMAGES_DIR/$TODAY"
echo "Created test directory for today: $(pwd)/$IMAGES_DIR/$TODAY"

# Display permissions
ls -la "$PROJECT_ROOT/upload"
ls -la "$IMAGES_DIR"

echo "Done! You can now start your application." 